<%--
公司等待竞单的列表
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%pageContext.setAttribute("APP_PATH", request.getContextPath());%>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta charset="utf-8" />
    <title>维修方</title>

    <meta name="description" content="Static &amp; Dynamic Tables" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
    <script src="${APP_PATH }/recourse/lib/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="${APP_PATH }/recourse/lib/layui/css/layui.css">
    <script type="text/javascript" src="${APP_PATH }/assets/js/xadmin.js"></script>
    <!-- bootstrap & fontawesome -->
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
    <style type="text/css">
        #addtest{
            border:1px #33CC00 solid;
            left: 20px;
        }

    </style>
    <style>
        @import url(https://fonts.googleapis.com/css?family=Open+Sans);
        body {
            padding: 20px;
            font: 1.4em/1.4em 'Open Sans', sans-serif;
        }
        .module {
            width: 450px;
            margin: 0 0 1em 0;
            overflow: hidden;
        }
        .module p {
            margin: 0;
        }

        .line-clamp {
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
        }

        .fade {
            position: relative;
            height: 3.6em; /* exactly three lines */
        }
        .fade:after {
            content: "";
            text-align: right;
            position: absolute;
            bottom: 0;
            right: 0;
            width: 70%;
            height: 1.2em;
            background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 50%);
        }

        .ftellipsis {
            height: 3.6em;
        }

        h1 {
            margin: 0 0 1em 0;
        }
        h2 {
            font-size: 1.2em;
        }

    </style>
</head>
<body >
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
    <ul class="layui-tab-title">
        <li class="layui-this">维修单详情</li>
        <li>图片描述</li>
        <li>视频描述</li>
        <li>维修单申请信息</li>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <table width="580" height="300"  border="0" cellpadding="0" cellspacing="0" style="margin-left: 40px;">
                <tr>
                    <td colspan="2"><b>维修单基本情况</b></td>
                </tr>
                <tr>
                    <td><b>维修单名称：</b>${order.order_name}</td>
                    <td><b>维修单编号：</b>${order.id}</td>
                </tr>
                <tr>
                    <td><b>维修单发起时间：</b><fmt:formatDate value="${order.createTime}" type="date"/></td>
                    <td><b>维修单拟定价格：</b>${order.second_price}元</td>
                </tr>
                <tr>
                    <td><b>设备管理员维修要求：</b>${b.equals("")?"无":a}</td>
                    <td><b>审核员维修要求：</b>${a.equals("")?"无":a}</td>
                </tr>
                <tr>
                    <td><b>所属单位：</b> ${order.insiderUnit_name}</td>
                    <td><b>维修单所属部门：</b>${order.department_id==1?"营房":(order.department_id==2?"装备":"公共")}</td>
                </tr>
                <tr>
                    <td>
                        <b>维修问题表述：</b><br>
                    </td>
                </tr>
            </table>
            <div  class="module line-clamp" style="background-color: #F5F5F5 ;height: 80px;margin-left: 40px; width: 600px;">
                ${order.problem_word}
            </div>
            <hr/>

        </div>
        <div class="layui-tab-item">
            <p>
                <c:forEach items="${photoes}" var="list" varStatus="status">
            <div class="img">
                <img border="12dp" src="/mmmsimage/${list}" alt="暂无图片信息">
            </div>
            </c:forEach>
            </p>
        </div>
        <div class="layui-tab-item">
            <br>
            <video width="320" height="240" style="margin-left: 200px;" controls autoplay>
                <source src="/mmmsimage/${video}" type="video/mp4">
                <object data="/mmmsimage/${video}" width="320" height="240">
                    <embed width="320" height="240" src="/mmmsimage/${order.problem_video}">
                </object>
            </video><br>
        </div>
        <div class="layui-tab-item">
                <div class="control-group">
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 125px;">预估价格</label>
                        <div class="layui-input-inline">
                            <input type="text" id = "price" name="price" required lay-verify="required" placeholder="请竞单的预估价格" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-form-mid layui-word-aux">元</div>
                    </div>
                </div>
                <div class="control-group">
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 125px;">开始维修时间</label>
                        <div class="layui-input-inline">
                            <input type="date" id = "start_time" name="start_time" required lay-verify="required" placeholder="请输入开始维修时间" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            <div class="control-group">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 125px;">结束维修时间</label>
                    <div class="layui-input-inline">
                        <input type="date" id = "end_time" name="end_time" required lay-verify="required" placeholder="请输入结束维修时间" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>

            <div class="control-group">
                <label class="layui-form-label" style="width: 125px;">预估维修清单</label>
                <table id="addtest">
                    <tr>
                        <td>材料名称</td>
                        <td>材料数量</td>
                        <td>材料单价</td>
                        <td>数量单位</td>
                    </tr>
                    <tr>
                        <td>
                            <input type="text" name="name1" id = "name1">
                        </td>
                        <td>
                            <input type="text" name="num1" id = "num1">
                        </td>
                        <td>
                            <input type="text" name="money1" id="money1">
                        </td>
                        <td>
                            <input type="text" name="classifer1" id="classifer1">
                        </td>
                    </tr>
                        <tr>
                            <td>
                                <input type="text" name="name2" id = "name2">
                            </td>
                            <td>
                                <input type="text" name="num2" id = "num2">
                            </td>
                            <td>
                                <input type="text" name="money2" id = "money2">
                            </td>
                            <td>
                                <input type="text" name="classifer2" id="classifer2">
                            </td>
                        </tr>
                </table>


            </div>

                <div class="control-group" style="margin-top: 30px;">
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label" style="width: 125px;">申请简述</label>
                        <div class="layui-input-inline" style="width: 320px">
                            <textarea id = "desc" name="desc" placeholder="请输入内容" class="layui-textarea" ></textarea>
                        </div>
                    </div>
                </div>
                <br>
                <input type="hidden" name="id" id = "id" value="${order.id}"/><br>
                <div><button id = "smit" class="layui-btn layui-btn-normal" type="submit" style="margin-left: 200px">提交申请</button></div>
        </div>
    </div>
</div>
<script>
    function fag2(video) {
        if(video===""){
            location.href="/mmmsimage/${order.solution_video}";
        }
        else{
            location.href="${pageContext.request.contextPath}/error";
        }
    }

    layui.use(['layer'], function() {
        var layer = layui.layer,
            $ = layui.jquery;
        $(document).on('click', '#smit', function () {
            var price= document.getElementById("price").value;
            var id = document.getElementById("id").value;
            var state = document.getElementById("desc").value;
            var start_time = document.getElementById("start_time").value;
            var end_time = document.getElementById("end_time").value;
            var arr1 = start_time.split("-");
            var arr2 = end_time.split("-");
            var date = new Date();

            var date1=new Date(parseInt(arr1[0]),parseInt(arr1[1])-1,parseInt(arr1[2]),0,0,0);
            var date2=new Date(parseInt(arr2[0]),parseInt(arr2[1])-1,parseInt(arr2[2]),0,0,0);
            var x = date1.getTime()-date2.getTime();
            var k = date1.getTime()-date.getTime();

            var name1 =document.getElementById("name1").value;
            var name2 =document.getElementById("name2").value;
            var num1 =document.getElementById("num1").value;
            var num2 =document.getElementById("num2").value;
            var money1 =document.getElementById("money1").value;
            var money2 =document.getElementById("money2").value;
            var classifer1 = document.getElementById("classifer1").value;
            var classifer2 = document.getElementById("classifer1").value;
            if(start_time===""||end_time===""){
                layer.alert("维修日期不可为空！");
                return false;
            }
            if(k+88255660<0){
                layer.alert("开始日期不可在目前之前！");
                return false;
            }
            if(x>0){
                layer.alert("开始日期不可在结束日期之后！");
                return false;
            }
            if(!/^\d+(\.\d+)?$/.test(price)){
                layer.alert("价格输入格式不正确！");
                price.focus();
                price.select();
                return false;
            }
            if(name1===""||name2===""||num1===""||num2===""||money1===""||money2===""){
                layer.alert("预计维修材料清单不可为空或为填完整！");
                return false;
            }
            if(!/^\d+(\.\d+)?$/.test(money1)||!/^\d+(\.\d+)?$/.test(money2)){
                layer.alert("材料单价格式不正确！");
                return false;
            }
            if(!/^[1-9][0-9]*$/.test(num1)||!/^[1-9][0-9]*$/.test(num2)){
                layer.alert("材料数量格式不正确！");
                return false;
            }
            if(parseFloat(price)>${order.second_price}&&${order.second_price}!==0.0){
                layer.alert("价格不能超过拟定价格！");
                return false;
            }
            var completeData = {
                "id":id,
                "price":price,
                "state":state,
                "start_time": start_time,
                "end_time":end_time,
                "name1":name1,
                "name2":name2,
                "num1":num1,
                "num2":num2,
                "money1":money1,
                "money2":money2,
                "classifer1":classifer1,
                "classifer2":classifer2
            };
            if(confirm("是否确认参与竞单/报价？")){
                $.ajax({
                    url:"${pageContext.request.contextPath}/company/submit",
                    type : "POST",
                    dataType:"json",
                    contentType : "application/json;charset=UTF-8",
                    data: JSON.stringify(completeData),
                    success:function(data) {
                    }
                });
                layer.alert("竞单成功", {
                        icon: 6
                    },
                    function() {
                        //关闭当前frame
                        xadmin.close();

                        // 可以对父窗口进行刷新
                        xadmin.father_reload();
                    });
            }else{
                return false;
            }

        });

    });

</script>



</body>
</html>




